@using DNA.Mvc.Text;
@model Thread
@{
    Layout = "~/Views/Shared/_LayoutPartial.cshtml";
    ViewBag.ImageUrl = "~/content/images/edit_page_48x48.png";
    ViewBag.Title = Html.Global("forums", "Move")+":" + Model.Title;
    var provider = ViewBag.Provider as HierarchicalNodeProviderBase;
    var post = new PostWrapper(Model.ThreadPost);
}
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken() 
    <table style="width: 100%;">
        <tr>
            <td style="vertical-align: top;">
                 <div class="d-forums-post-body">
                    <table style="width: 100%">
                        <tr>
                            <td class="d-forums-post-profile" style="vertical-align: top;">
                                <div style="display: inline-block">
                                    <img src="@Url.Content("~/content/images/calendar_empty_16.png")" alt="postby" style="float: left;" />
                                    @Html.Global(post.Posted)
                                </div>
                                @if (post.UserProfile != null)
                                {
                                    Html.RenderPartial("UserInfo", post.UserProfile);
                                }
                            </td>
                            <td class="d-forums-post-content" style="vertical-align: top;">
                                <div style="height: 300px; overflow: auto;">
                                    @TextEngine.BBCode(post.Body, true, false, true)
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
            <td style="width: 300px; vertical-align: top;">
                @Html.Hidden("ForumID")
                @(Ajax.Dna().TreeView("forumTree")
                           .Options(opts =>
                           {
                               opts.OnNodeSelected = "var _isgroup=$(node).attr('isgroup'); if (_isgroup) $(\"#btnMove\").hide(); else { $(\"#btnMove\").show(); $('#ForumID').val($(node).attr('key'));}";
                           })
                           .Bind<HierarchicalNode>(provider.RootNode, (node =>
                           {
                               if (node.Item != null)
                               {
                                   var forum = (Forum)node.Item;
                                   if (forum.IsGroup)
                                   {
                                       node.Attributes.Add("isgroup", "true");
                                       node.ImageUrl = Url.Content("~/content/images/icon_comments_16.png");
                                   }
                                   else
                                   {
                                       node.ImageUrl = Url.Content("~/content/images/comment.png");
                                       node.Title += " (" + forum.Threads.Count().ToString() + ")";
                                   }
                               }
                               else
                               {
                                   node.ImageUrl = Url.Content("~/content/images/users_16.png");
                               }
                               node.NavigateUrl = "javascript:void(0);";
                               return true;
                           })).GetHtml()
                          )
            </td>
        </tr>
    </table>
    <div style="text-align: center; overflow: auto;">
        <center>
            @(Ajax.Dna().Button("btnMove")
                       .HtmlAttributes(new { style = "padding-top: 15px;display:none;" })
                       .ChangeType(ButtonTypes.LinkButton)
                       .Submit()
                       .ToolTip(Html.Global("forums", "Move"))
                       .NavigateUrl("javascript:void(0);")
                       .Images(Url.ThemeContent("images/ui-forum-Move.png"), Url.ThemeContent("images/ui-forum-Move-hover.png"))
                       .GetHtml()
           )
        </center>
    </div>
}
@section SiteMapPath{
    @Ajax.ForumMapPath(Model.ForumID)
}
